#include "stdafx.h"
#import "progid:HelloServer.Hello.1" no_namespace

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

	try{
		IHelloPtr pIHello(__uuidof(Hello));

		BSTR message = NULL;
		BSTR name;
		char buffer[256];
		cout << "Insert Your name : ";
		cin >> buffer;

		name = A2BSTR(buffer);		
		pIHello->sayHello(name, &message);
		USES_CONVERSION;
		cout << W2A(message) << endl;

		::CoTaskMemFree((LPVOID)message);
	}
	catch(_com_error& e){
		cout << e.ErrorMessage() << endl;
	}

	::CoUninitialize();
	return 0;
}

